﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace eTerm.Platform.Web.App_Code
{
    public abstract class BaseIListEntityUserControl<T>:BaseEntityUserControl<T> where T :new ()
    {
        protected virtual IList<T> GetIListEntityFromDb()
        {
            return default(List<T>);
        }

        protected virtual IList<T> GetIListEntityFromControl()
        {
            return default(List<T>);
        }

        protected virtual void SaveIListEntity(IList<T> model)
        {
            model.ToList().ForEach(l => {
                SaveEntity(l);
            });
        }

        public void SaveIList()
        {
            IList<T> model = GetIListEntityFromControl();
            SaveIListEntity(model);
        }

    }
}
